package com.snjgm.request_network_server;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * @author: snjgm
 * data: 2022/8/16
 * description:
 */
public class AlarmReceiver extends BroadcastReceiver {
    private static final String  TAG = "AlarmReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        int actionType = intent.getIntExtra("action_type",-1);
        Log.d(TAG, "广播接受者中接收到的actionType为: "+actionType);
        if (intent != null) {
            Log.d(TAG,"广播接受者成功接收到了广播");
            Log.d(TAG, "action的值: "+actionType);
            switch (actionType) {
                case Constants.MSG_FROM_SERVICE:
                    Log.d(TAG, "onReceive: MSG_FROM_SERVICE");
                    intent.setClass(context,RequestNetWorkService.class);
                    break;
                default:
                    Log.d(TAG, "onReceiver: 不好意思,接受者没有接收到正确的值");
                    break;
            }
        }
        context.startService(intent);
    }
}
